package Vista;

import Dominio.ApuestaData;
import Dominio.Dom_Fachada;

import com.opensymphony.xwork2.ActionSupport;

public class EliminarApuesta extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String id;

	public String execute() {
		try {
			new Dom_Fachada().deleteApuesta(new ApuestaData(Integer
					.parseInt(id)));
			return SUCCESS;
		} catch (Exception e) {
			System.err.println(e.toString());
		}
		return ERROR;
	}

	public void validate() {
		if (id.length() > 0) {
			try {
				Integer.parseInt(id);
			} catch (Exception e) {
				System.err.println(e.toString());
				addFieldError("id", "ID inválido, debe ser numérico.");
			}
		} else {
			addFieldError("id", "Inserte un número.");
		}
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
}
